import '@teld/q-components/style.css';

import './style/variables.css';
import './style/variables.scss';

import './style/global.scss';
import './style/index.scss';
import './style/override.scss';

/**
 * changelog: 2023-01-10
 * DevExtreme组件依赖的样式
 * 1.dx.light.css基础样式
 * 2.override.devextreme.scss 兼容处理
 */
import 'devextreme/dist/css/dx.light.css';
import './style/override.devextreme.scss';
/** END changelog: 2023-01-10 */

import Quasar, { Dialog, Notify } from '@teld/q-components';
export * from '@teld/q-components';

export {
  AddressbarColor,
  AppFullscreen,
  AppVisibility,
  BottomSheet,
  ClosePopup,
  Cookies,
  Dark,
  Dialog,
  EventBus,
  Intersection,
  Loading,
  // LoadingBar,
  LocalStorage,
  Meta,
  Morph,
  Mutation,
  Notify,
  Platform,
  Ripple,
  Screen,
  Scroll,
  ScrollFire,
  SessionStorage,
  TouchHold,
  TouchPan,
  TouchRepeat,
  TouchSwipe,
  clone,
  colors,
  copyToClipboard,
  createMetaMixin,
  createUploaderComponent,
  date,
  debounce,
  dom,
  event,
  exportFile,
  extend,
  format,
  frameDebounce,
  getCssVar,
  is,
  morph,
  noop,
  openURL,
  patterns,
  runSequentialPromises,
  scroll,
  setCssVar,
  throttle,
  uid,
  useDialogPluginComponent,
  useFormChild,
  useMeta,
  useQuasar,

} from '@teld/q-components';

import TAjaxBar from './basic/ajax-bar';
import TAnchor from './basic/anchor';
import TAvatar from './basic/avatar';
import TBadge from './basic/badge';
import TBanner from './basic/banner';
import TBar from './basic/bar';
import TBreadcrumbs from './basic/breadcrumbs';
import TButton from './basic/button';
import TButtonDropdown from './basic/button-dropdown';
import TButtonGroup from './basic/button-group';
import TButtonToggle from './basic/button-toggle';
import TCard from './basic/card';
import TCarousel from './basic/carousel';
import TChat from './basic/chat';
import TCheckbox from './basic/checkbox';
import TCheckboxGroup from './basic/checkbox-group';
import TChip from './basic/chip';
import TChips from './basic/chips';
import TCircularProgress from './basic/circular-progress';
import TColor from './basic/color';
import TDate from './basic/date';
import TDateTime from './basic/date-time';
import TDialog from './basic/dialog';
import TDialogBottomSheet from './basic/dialog-bottom-sheet';
import TDialogPlugin from './basic/dialog-plugin';
import TDrawer from './basic/drawer';
import TEditor from './basic/editor';
import TAdvancedEditor from './bussiness/advanced-editor/index.js';
import TExpansion from './basic/expansion';
import TExpansionItem from './basic/expansion-item';
import TFab from './basic/fab';
import TField from './basic/field';
import TFile from './basic/file';
import TFooter from './basic/footer';
import TForm from './basic/form';
import THeader from './basic/header';
import THelp from './basic/help';
import TIcon from './basic/icon';
import TImg from './basic/img';
import TImportExport from './basic/import-export/index.js';
import TInfiniteScroll from './basic/infinite-scroll';
import TInnerLoading from './basic/inner-loading';
import TInput from './basic/input';
import TInputNumber from './basic/inputNumber';
import TIntersection from './basic/intersection';
import TItem from './basic/item';
import TItemLabel from './basic/item-label';
import TItemSection from './basic/item-section';
import TKnob from './basic/knob';
import TLabel from './basic/label';
import TLayout from './basic/layout';
import TLayoutGrid from './basic/layout-grid';
import TLinearProgress from './basic/linear-progress';
import TLink from './basic/link';
import TList from './basic/list';
import TMarkupTable from './basic/markup-table';
import TMenu from './basic/menu';
import TNoSsr from './basic/no-ssr';
import TOptionGroup from './basic/option-group';
import TPage from './basic/page';
import TPageScroller from './basic/page-scroller';
import TPageSticky from './basic/page-sticky';
import TPagination from './basic/pagination';
import TParallax from './basic/parallax';
import TPopupEdit from './basic/popup-edit';
import TPopupProxy from './basic/popup-proxy';
import TPullToRefresh from './basic/pull-to-refresh';
import TRadio from './basic/radio';
import TRadioGroup from './basic/radio-group';
import TRange from './basic/range';
import TRating from './basic/rating';
import TResizeObserver from './basic/resize-observer';
import TResponsive from './basic/responsive';
import TScrollArea from './basic/scroll-area';
import TScrollObserver from './basic/scroll-observer';
import TSelect from './basic/select';
import TSeparator from './basic/separator';
import TSkeleton from './basic/skeleton';
import TSlideItem from './basic/slide-item';
import TSlideTransition from './basic/slide-transition';
import TSlider from './basic/slider';
import TSpace from './basic/space';
import TSpinner from './basic/spinner';
import TSplitter from './basic/splitter';
import TStep from './basic/step';
import TStepper from './basic/stepper';
import TStateLabel from './bussiness/state-label';
// import TStepp from './basic/stepp';
import TTabPanel from './basic/tab-panel';
import TTable from './basic/table';
import TTabs from './basic/tabs';
import TTextarea from './basic/textarea';
import TTime from './basic/time';
import TTimeline from './basic/timeline';
import TToggle from './basic/toggle';
import TToolbar from './basic/toolbar';
import TTooltip from './basic/tooltip';
import TTree from './basic/tree';
import TUploader from './basic/uploader';
import TVideo from './basic/video';
import TVirtualScroll from './basic/virtual-scroll';
import TChartBar from './bussiness/charts/bar';
import TChartBarLine from './bussiness/charts/barline';
import TChartLine from './bussiness/charts/line';
import TChartPie from './bussiness/charts/pie';
import TChartRadar from './bussiness/charts/radar';
import TChartStrip from './bussiness/charts/strip';
import TDataGrid from './bussiness/data-grid';
import TPrefabPagination from './bussiness/prefab-pagination';
import TTreeList from './bussiness/tree-list';
import TQuickFilter from './bussiness/quick-filter';
import TCopilot from './bussiness/copilot';
import TFilter from './bussiness/filter';
import TTagFilter from './bussiness/tag-filter';
import TMixedView from './bussiness/mixed-view';
import TMultilingual from './bussiness/multilingual';
import TPopupSearch from './bussiness/popup-search';
import TPopupFilter from './bussiness/popup-filter';
import TSelectHelper from './bussiness/select-helper';
import TStateMachine from './bussiness/state-machine';

import TQueryPlanM from './bussiness/query-plan/m';
import TQueryPlanP from './bussiness/query-plan/p';

import TCurrency from './bussiness/currency';
import TDiscount from './bussiness/discount';
//
import TRepeat from './bussiness/repeat';
import TComment from './bussiness/comment';
import TImagePreview from './bussiness/image-preview';
import TMarkdown from './bussiness/markdown';
//
import TSelectTreeHelper from './bussiness/select-tree-helper';

import TEditTable from './bussiness/edit-table';
import TPortal from './bussiness/portal';
import TTextLabel from './bussiness/text-label';
import TMultidimensionalTable from './bussiness/multidimensional-table';
const components = [
  TMultidimensionalTable,
  TCurrency,
  TAjaxBar,
  TAvatar,
  TBadge,
  TBanner,
  TBar,
  TBreadcrumbs,
  TButton,
  TButtonDropdown,
  TButtonGroup,
  TButtonToggle,
  TCard,
  TCarousel,
  TChat,
  TCheckbox,
  TChip,
  TChips,
  TImportExport,
  TCircularProgress,
  TColor,
  TDate,
  TDialog,
  TDialogBottomSheet,
  TDialogPlugin,
  TDrawer,
  TEditor,
  TAdvancedEditor,
  TExpansion,
  TExpansionItem,
  TFab,
  TField,
  TFile,
  TFooter,
  TForm,
  THeader,
  TIcon,
  TImg,
  TInfiniteScroll,
  TInnerLoading,
  TInput,
  TInputNumber,
  TIntersection,
  TItem,
  TList,
  TItemSection,
  TItemLabel,
  TKnob,
  TLayout,
  TLayoutGrid,
  TLinearProgress,
  TMarkupTable,
  TMenu,
  TNoSsr,
  TOptionGroup,
  TPage,
  TPageScroller,
  TPageSticky,
  TPagination,
  TParallax,
  TPopupEdit,
  TPopupProxy,
  TPullToRefresh,
  TRadio,
  TRange,
  TRating,
  TResizeObserver,
  TResponsive,
  TScrollArea,
  TScrollObserver,
  TSelect,
  TSeparator,
  TSkeleton,
  TSlideItem,
  TSlideTransition,
  TSlider,
  TSpace,
  TSplitter,
  TSpinner,
  TStepper,
  TStateLabel,
  // TStepp,
  TStep,
  TTabPanel,
  TTable,
  TTabs,
  TAnchor,
  TTime,
  TTimeline,
  TToggle,
  TToolbar,
  TTooltip,
  TTree,
  TUploader,
  TVideo,
  TVirtualScroll,
  TLabel,
  TLink,
  THelp,
  TRadioGroup,
  TTextarea,
  TSelectHelper,
  TCheckboxGroup,
  TDateTime,
  TChartBar,
  TDataGrid,
  TPrefabPagination,
  TTreeList,
  TQuickFilter,
  TCopilot,
  TMixedView,
  TPopupSearch,
  TPopupFilter,
  TChartPie,
  TChartLine,
  TChartStrip,
  TChartBarLine,
  TChartRadar,
  TQueryPlanM,
  TQueryPlanP,
  TStateMachine,
  TMultilingual,
  TFilter,
  TTagFilter,
  TDiscount,
  TRepeat,
  TComment,
  TImagePreview,
  TMarkdown,
  TSelectTreeHelper,
  TEditTable,
  TPortal,
  TTextLabel,
];

export {
  TMultidimensionalTable,
  TAjaxBar,
  TAnchor,
  TAvatar,
  TBadge,
  TBanner,
  TBreadcrumbs,
  TButton,
  TButtonDropdown,
  TButtonGroup,
  TButtonToggle,
  TCard,
  TCarousel,
  TChartBar,
  TChartBarLine,
  TChartLine,
  TChartPie,
  TChartStrip,
  TChartRadar,
  TChat,
  TCheckbox,
  TCheckboxGroup,
  TChip,
  TChips,
  TCircularProgress,
  TColor,
  TCurrency,
  TDataGrid,
  TPrefabPagination,
  TTreeList,
  TQuickFilter,
  TCopilot,
  TDate,
  TDateTime,
  TDialog,
  TDialogBottomSheet,
  TDialogPlugin,
  TDiscount,
  TDrawer,
  TEditor,
  TAdvancedEditor,
  TExpansion,
  TExpansionItem,
  TFab,
  TField,
  TFile,
  TFilter,
  TTagFilter,
  TFooter,
  TForm,
  THeader,
  THelp,
  TIcon,
  TImg,
  TImportExport,
  TInfiniteScroll,
  TInnerLoading,
  TInput,
  TInputNumber,
  TIntersection,
  TItem,
  TItemLabel,
  TItemSection,
  TKnob,
  TLabel,
  TLayout,
  TLayoutGrid,
  TLinearProgress,
  TLink,
  TList,
  TMarkupTable,
  TMenu,
  TMixedView,
  TMultilingual,
  TNoSsr,
  TOptionGroup,
  TPage,
  TPageScroller,
  TPageSticky,
  TPagination,
  TParallax,
  TPopupEdit,
  TPopupProxy,
  TPopupSearch,
  TPopupFilter,
  TPullToRefresh,
  TQueryPlanM,
  TQueryPlanP,
  TRadio,
  TRadioGroup,
  TRange,
  TRating,
  TRepeat,
  TComment,
  TImagePreview,
  TMarkdown,
  TResizeObserver,
  TResponsive,
  TScrollArea,
  TScrollObserver,
  TSelect,
  TSelectHelper,
  TSelectTreeHelper,
  TSeparator,
  TSkeleton,
  TSlideItem,
  TSlideTransition,
  TSlider,
  TSpace,
  TSpinner,
  TSplitter,
  TStateMachine,
  TStep,
  // TStepp,
  TStepper,
  TStateLabel,
  TTabPanel,
  TTable,
  TTabs,
  TTextarea,
  TTime,
  TTimeline,
  TToggle,
  TToolbar,
  TTooltip,
  TTree,
  TUploader,
  TVideo,
  TVirtualScroll,
  TEditTable,
  TPortal,
  TTextLabel,
};

import { merge } from 'lodash';
import { zhCN as defaultLang } from './lang';
import zhCN_ from './lang/support/zh-CN.js';

export default {
  install(app, options, ssrContext) {
    Quasar.install(app, options, ssrContext);
    Quasar.lang.set(merge({}, defaultLang, zhCN_), ssrContext);
    window.fasAppInstance = app;
    app.component('TButton', TButton);
    app.component('TButtonDropdown', TButtonDropdown);
    app.component('TButtonGroup', TButtonGroup);
    app.component('TButtonToggle', TButtonToggle);
    components.forEach(v => {
      app.use(v, options, ssrContext);
      // console.log(v.name);
    });

    window.TComponents ||= {};

    window.TComponents.IconList = {
      common:'fas dx-icon',
      arrowUp: 'icon-t-arrow-up',
      arrowDown: 'icon-t-arrow-down',
      arrowLeft: 'icon-t-arrow-left',
      arrowRight: 'icon-t-arrow-right',
    };

    window.TComponents.notify = function (params) {
      return Notify.create({
        position: 'top-right',
        ...params,
      });
    };
    window.TComponents.toast = function (params) {
      return Notify.create({
        position: 'center',
        ...params,
      });
    };
    // https://www.quasar-cn.cn/quasar-plugins/notify
    // window.TComponents.notify({
    //   message: 'Danger, Will Robinson! Danger!',
    // });

    window.TComponents.dialog = Dialog.create;

    window.TComponents.confirm = function (params) {
      return Dialog.create({
        cancel: true,
        persistent: true,
        ...params,
      });
    };
    // window.TComponents.confirm({
    //   title: 'Confirm',
    //   message: 'Would you like to turn on the wifi?',
    // })
    //   .onOk(() => {
    //     console.log('>>>> OK');
    //   })
    //   .onOk(() => {
    //     console.log('>>>> second OK catcher');
    //   })
    //   .onCancel(() => {
    //     console.log('>>>> Cancel');
    //   })
    //   .onDismiss(() => {
    //     console.log('I am triggered on both OK and Cancel');
    //   });
  },
};
